package qmlt.learning.neuralnetwork.control;

import java.util.Map;

import qmlt.dataset.DataSet;
import qmlt.learning.neuralnetwork.NeuralNetwork;

@SuppressWarnings("unchecked")
public class AnotherNeuralNetworkController extends BasicNeuralNetworkController
{

	public AnotherNeuralNetworkController(Map<String, Float> outputConversionMap,
			DataSet validationSet, int nInputs, int... nHiddenLayerNodes)
	{
		super(outputConversionMap, validationSet, nInputs, nHiddenLayerNodes);
		// TODO Auto-generated constructor stub
	}

	public AnotherNeuralNetworkController(String posString, Float posValue, String negString,
			Float negValue, DataSet validationSet, int nInputs, int... nHiddenLayerNodes)
	{
		super(posString, posValue, negString, negValue, validationSet, nInputs, nHiddenLayerNodes);
		// TODO Auto-generated constructor stub
	}

	public AnotherNeuralNetworkController(DataSet validationSet, int nInputs,
			int[] nHiddenLayerNodes)
	{
		super(validationSet, nInputs, nHiddenLayerNodes);
		// TODO Auto-generated constructor stub
	}

	public int	minIteration	= 10000;

	@Override
	public boolean ifStop(NeuralNetwork ann, int iteration)
	{
		float score = evaluator.evaluate(ann, validateSet);
		if (score > bestScore)
		{
			bestScore = score;
			bestIter = iteration;
		}
		if (verbose)
		{
			out.format("iter:%d, score:%f\n", iteration, score);
		}
		if (iteration > minIteration && bestIter < iteration / 2)
		{
			if (verbose)
				out.format("best iter:%d, best score:%f\n", bestIter, bestScore);
			return true;
		}
		return false;
	}

}
